package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.saas.enums.business.InvoiceEnum;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;

/**
 * 打印 回款单回款金额 枚举
 *
 * @author 徐俊杰
 * @date 2019/12/3 10:22
 * @since v1.0
 */
@Getter
public enum PrintInvoiceTotalMoneyEnum {

    /**
     * 关联合同
     */
    CONTRACT_ID(InvoiceEnum.CONTRACT_ID.getAttr(), InvoiceEnum.CONTRACT_ID.getI18nAttrName(),0),
    /**
     * 关联回款
     */
    PAYMENT_ID(InvoiceEnum.PAYMENT_ID.getAttr(), "enum.printinvoicetotalmoney.name.payment_id", 1),
    /**
     * 开票金额
     */
    TOTAL_MONEY(InvoiceEnum.TOTAL_MONEY.getAttr(), InvoiceEnum.TOTAL_MONEY.getI18nAttrName(),2),
    ;
    private String attr;
    private String name;
    private int sort;

    PrintInvoiceTotalMoneyEnum(String attr, String name, int sort) {
        this.attr = attr;
        this.name = name;
        this.sort = sort;
    }


    public static List<PrintInvoiceTotalMoneyEnum> getAllEnum() {
        List<PrintInvoiceTotalMoneyEnum> list = new ArrayList<>();
        Collections.addAll(list, values());
        return list;
    }

    public static PrintInvoiceTotalMoneyEnum getByAttr(String alias) {
        for (PrintInvoiceTotalMoneyEnum cacheCode : values()) {
            if (cacheCode.getAttr().equals(alias)) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
